package com.xiaoshuidi.cloud.framework.filings.core.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 房源类型
 *
 * @Author Feng
 * @date 2023/5/5
 */
@Getter
@AllArgsConstructor
public enum HouseLayoutEnum {
    STUDIO(1, "一户室"),
    TWO_BH(2, "二户室"),
    THREE_BH(3, "三户室"),
    FOUR_BH(4, "四户室"),
    ABOVE_FOUR_BH(5, "四户室以上");


    private int code;
    private String name;


    public static Integer getCodeByName(String name) {
        if (StrUtil.isEmpty(name)) {
            return null;
        }
        Optional<HouseLayoutEnum> find = Arrays.stream(HouseLayoutEnum.values()).filter(s -> s.getName().equals(name)).findFirst();
        if (find.isPresent()) {
            return find.get().getCode();
        }
        return null;
    }
}
